package com.sthz.facepay.mapper;

import com.sthz.facepay.model.Storagerule;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface StorageruleMapper {
    @Delete({
        "delete from st_storagerule",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into st_storagerule (id, name, ",
        "money, discount, ",
        "state)",
        "values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{money,jdbcType=DOUBLE}, #{discount,jdbcType=VARCHAR}, ",
        "#{state,jdbcType=TINYINT})"
    })
    int insert(Storagerule record);

    @InsertProvider(type=StorageruleSqlProvider.class, method="insertSelective")
    int insertSelective(Storagerule record);

    @Select({
        "select",
        "id, name, money, discount, state",
        "from st_storagerule",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="money", property="money", jdbcType=JdbcType.DOUBLE),
        @Result(column="discount", property="discount", jdbcType=JdbcType.VARCHAR),
        @Result(column="state", property="state", jdbcType=JdbcType.TINYINT)
    })
    Storagerule selectByPrimaryKey(Integer id);

    @UpdateProvider(type=StorageruleSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Storagerule record);

    @Update({
        "update st_storagerule",
        "set name = #{name,jdbcType=VARCHAR},",
          "money = #{money,jdbcType=DOUBLE},",
          "discount = #{discount,jdbcType=VARCHAR},",
          "state = #{state,jdbcType=TINYINT}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Storagerule record);
}